pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java
@@ -4,6 +4,8 @@ import com.dy.pipIrrGlobal.pojoOp.OpeTrack; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * @author ZhuBaoMin * @date 2024-09-24 10:08 @@ -24,4 +26,11 @@ int updateByPrimaryKeySelective(OpeTrack record); int updateByPrimaryKey(OpeTrack record); /** * 批量添加巡检轨迹 * @param list * @return */ int insertTracks(List<OpeTrack> list); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientTempMapper.java
New file @@ -0,0 +1,36 @@ package com.dy.pipIrrGlobal.daoSe; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoSe.SeClientTemp; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * @author ZhuBaoMin * @date 2024-09-26 14:57 * @LastEditTime 2024-09-26 14:57 * @Description */ @Mapper public interface SeClientTempMapper extends BaseMapper<SeClientTemp> { int deleteByPrimaryKey(Integer id); int insert(SeClientTemp record); int insertSelective(SeClientTemp record); SeClientTemp selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(SeClientTemp record); int updateByPrimaryKey(SeClientTemp record); /** * 根据镇名获取农户 * @param townName * @return */ List<SeClientTemp> getClientsByTownName(String townName ); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeClientTemp.java
New file @@ -0,0 +1,62 @@ package com.dy.pipIrrGlobal.pojoSe; /** * @author ZhuBaoMin * @date 2024-09-26 14:57 * @LastEditTime 2024-09-26 14:57 * @Description */ import com.baomidou.mybatisplus.annotation.TableName; import com.dy.common.po.BaseEntity; import lombok.*; /** * 农户临时表 */ @TableName(value = "se_client_temp", autoResultMap = true) @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor public class SeClientTemp implements BaseEntity { public static final long serialVersionUID = 202409261459001L; /** * 主键 */ private Integer id; /** * 镇 */ private String town; /** * 村 */ private String village; /** * 姓名 */ private String name; /** * 身份证号 */ private String idcard; /** * 手机号 */ private String phone; /** * 街道及门牌号 */ private String address; } pipIrr-platform/pipIrr-global/src/main/resources/application-database-test.yml
@@ -6,8 +6,8 @@ type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://192.168.40.166:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://8.130.130.233:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://127.0.0.1:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://8.130.130.233:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://127.0.0.1:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull username: root password: dysql,;.abc!@# druid: pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml
@@ -99,4 +99,13 @@ locate_time = #{locateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} </update> <!--批量添加巡检轨迹--> <insert id="insertTracks"> INSERT INTO ope_track (id, inspect_id, lng, lat, locate_time) VALUES <foreach collection="list" item="item" index="index" separator=","> (#{item.id}, #{item.inspectId}, #{item.lng}, #{item.lat}, #{item.locateTime}) </foreach> </insert> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientTempMapper.xml
New file @@ -0,0 +1,125 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.dy.pipIrrGlobal.daoSe.SeClientTempMapper"> <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClientTemp"> <!--@mbg.generated--> <!--@Table se_client_temp--> <id column="id" jdbcType="INTEGER" property="id" /> <result column="town" jdbcType="VARCHAR" property="town" /> <result column="village" jdbcType="VARCHAR" property="village" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="idCard" jdbcType="VARCHAR" property="idcard" /> <result column="phone" jdbcType="VARCHAR" property="phone" /> <result column="address" jdbcType="VARCHAR" property="address" /> </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> id, town, village, `name`, idCard, phone, address </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <!--@mbg.generated--> select <include refid="Base_Column_List" /> from se_client_temp where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <!--@mbg.generated--> delete from se_client_temp where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientTemp" useGeneratedKeys="true"> <!--@mbg.generated--> insert into se_client_temp (town, village, `name`, idCard, phone, address ) values (#{town,jdbcType=VARCHAR}, #{village,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{idcard,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR} ) </insert> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientTemp" useGeneratedKeys="true"> <!--@mbg.generated--> insert into se_client_temp <trim prefix="(" suffix=")" suffixOverrides=","> <if test="town != null"> town, </if> <if test="village != null"> village, </if> <if test="name != null"> `name`, </if> <if test="idcard != null"> idCard, </if> <if test="phone != null"> phone, </if> <if test="address != null"> address, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="town != null"> #{town,jdbcType=VARCHAR}, </if> <if test="village != null"> #{village,jdbcType=VARCHAR}, </if> <if test="name != null"> #{name,jdbcType=VARCHAR}, </if> <if test="idcard != null"> #{idcard,jdbcType=VARCHAR}, </if> <if test="phone != null"> #{phone,jdbcType=VARCHAR}, </if> <if test="address != null"> #{address,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientTemp"> <!--@mbg.generated--> update se_client_temp <set> <if test="town != null"> town = #{town,jdbcType=VARCHAR}, </if> <if test="village != null"> village = #{village,jdbcType=VARCHAR}, </if> <if test="name != null"> `name` = #{name,jdbcType=VARCHAR}, </if> <if test="idcard != null"> idCard = #{idcard,jdbcType=VARCHAR}, </if> <if test="phone != null"> phone = #{phone,jdbcType=VARCHAR}, </if> <if test="address != null"> address = #{address,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClientTemp"> <!--@mbg.generated--> update se_client_temp set town = #{town,jdbcType=VARCHAR}, village = #{village,jdbcType=VARCHAR}, `name` = #{name,jdbcType=VARCHAR}, idCard = #{idcard,jdbcType=VARCHAR}, phone = #{phone,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> <!--根据镇名获取农户--> <select id="getClientsByTownName" resultType="com.dy.pipIrrGlobal.pojoSe.SeClientTemp"> SELECT * FROM se_client_temp WHERE town = #{townName} </select> </mapper> pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml
@@ -3,9 +3,8 @@ datasource: #配置数据源 type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://8.130.130.233:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://127.0.0.1:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://8.130.130.233:3306/pipIrr_test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull username: root password: dysql,;.abc!@# druid: pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/PipIrrAppApplication.java
@@ -18,7 +18,7 @@ }) } ) @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoRm", "com.dy.pipIrrGlobal.daoPr", "com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa"}) @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoOp", "com.dy.pipIrrGlobal.daoBa"}) public class PipIrrAppApplication { public static void main(String[] args) { pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java
@@ -1,9 +1,26 @@ package com.dy.pipIrrApp.inspect; import com.dy.common.aop.SsoAop; import com.dy.common.util.IDLongGenerator; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrApp.inspect.dto.Inspects; import com.dy.pipIrrGlobal.pojoOp.OpeInspect; import com.dy.pipIrrGlobal.pojoOp.OpeTrack; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; import java.util.Objects; /** * @author ZhuBaoMin @@ -19,4 +36,73 @@ @Autowired private InspectSv inspectSv; private final IDLongGenerator idLongGenerator; public InspectCtrl(IDLongGenerator idLongGenerator) { this.idLongGenerator = idLongGenerator; } /** * 添加巡检轨迹 * @param list_Inspects 巡检对象数组 * @param bindingResult * @return */ @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> save(@RequestBody @Valid List<Inspects> list_Inspects, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } if(list_Inspects != null && list_Inspects.size() > 0) { for (int i = 0; i < list_Inspects.size(); i++) { Inspects inspects = list_Inspects.get(i); Long inspectorId = inspects.getInspectorId(); Long inspectId = inspects.getInspectId(); Date startTime = inspects.getStartTime(); Date stopTime = inspects.getStopTime(); List<OpeTrack> tracks = inspects.getTracks(); if(tracks == null || tracks.size() == 0) { return BaseResponseUtils.buildErrorMsg("无巡检轨迹"); } if(inspectId == null || inspectId.equals(0)) { // 该巡检未上传过记录 // 添加巡检记录 OpeInspect opeInspect = new OpeInspect(); opeInspect.setInspectorId(inspects.getInspectorId()); if(startTime != null) { opeInspect.setStartTime(startTime); } if(stopTime != null) { opeInspect.setStopTime(stopTime); } inspectId = inspectSv.addInspect(opeInspect); if(inspectId == null) { return BaseResponseUtils.buildErrorMsg("巡检记录添加失败"); } for (int j = 0; j < tracks.size(); j++) { tracks.get(j).setId(idLongGenerator.generate()); tracks.get(j).setInspectId(inspectId); } Integer rec = inspectSv.insertTracks(tracks); if(rec == null || rec == 0) { return BaseResponseUtils.buildErrorMsg("巡检轨迹添加失败"); } }else { // 该巡检已上传过记录,续传 } } return BaseResponseUtils.buildSuccess() ; } return BaseResponseUtils.buildErrorMsg("您提交的巡检轨迹为空"); } } pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java
@@ -2,9 +2,13 @@ import com.dy.pipIrrGlobal.daoOp.OpeInspectMapper; import com.dy.pipIrrGlobal.daoOp.OpeTrackMapper; import com.dy.pipIrrGlobal.pojoOp.OpeInspect; import com.dy.pipIrrGlobal.pojoOp.OpeTrack; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * @author ZhuBaoMin @@ -21,4 +25,25 @@ @Autowired private OpeTrackMapper opeTrackMapper; /** * 添加巡检记录 * @param po * @return */ public Long addInspect(OpeInspect po) { opeInspectMapper.insert(po); return po.getId(); } /** * 批量添加巡检轨迹 * @param list * @return */ public Integer insertTracks(List<OpeTrack> list) { return opeTrackMapper.insertTracks(list); } } pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/dto/Inspects.java
New file @@ -0,0 +1,48 @@ package com.dy.pipIrrApp.inspect.dto; import com.dy.pipIrrGlobal.pojoOp.OpeTrack; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.Data; import java.util.Date; import java.util.List; /** * @author ZhuBaoMin * @date 2024-09-24 15:17 * @LastEditTime 2024-09-24 15:17 * @Description 巡检对象 */ @Data public class Inspects { public static final long serialVersionUID = 202409241517001L; /** * 巡检员ID */ @NotNull(message = "巡检员不能为空") private Long inspectorId; /** * 巡检ID,该次巡检已提交过记录时有值,主要用于后续打点。 */ private Long inspectId; /** * 开始巡检时间 */ private Date startTime; /** * 结束巡检时间 */ private Date stopTime; /** * 巡检轨迹 */ @NotEmpty(message = "巡检轨迹不能为空") private List<OpeTrack> tracks; } pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/resources/application.yml
@@ -3,8 +3,8 @@ include: global, database, database-ym, database-pj, database-test user: defaultTrueRandomFalsePassword: true #true:采用默认密码,false:系统产生随机密码 defaultPassword: "abc_123" # defaultPassword: "admin" # defaultPassword: "abc_123" defaultPassword: "admin" #actutor的web端口 management: pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/clientTemp/ClientTempCtrl.java
New file @@ -0,0 +1,117 @@ package com.dy.pipIrrSell.clientTemp; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrGlobal.pojoSe.SeClient; import com.dy.pipIrrGlobal.pojoSe.SeClientTemp; import com.dy.pipIrrSell.client.ClientSv; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; /** * @author ZhuBaoMin * @date 2024-09-26 15:03 * @LastEditTime 2024-09-26 15:03 * @Description */ @Slf4j @RestController @RequestMapping(path = "client_temp") @RequiredArgsConstructor public class ClientTempCtrl { private final ClientTempSv clientTempSv; private final ClientSv clientSv; /** * 导入农户 * @param townName * @return */ @PostMapping(path = "import") @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> importClient(String townName){ List<SeClientTemp> list_client = clientTempSv.getClientsByTownName(townName); if(list_client != null && list_client.size() > 0) { JSONArray array_Clients = (JSONArray) JSON.toJSON(list_client); for (int i = 0; i < array_Clients.size(); i++) { JSONObject job_client = array_Clients.getJSONObject(i); String town = job_client.getString("town"); String village = job_client.getString("village"); String name = job_client.getString("name"); String idCard = job_client.getString("idcard"); String phone = job_client.getString("phone"); if(phone != null && phone.length() > 11) { phone = phone.substring(0,11); } String address = job_client.getString("address"); if(town.trim().equals("元马镇6号")) { SeClient client = new SeClient(); //client.setCountyid(28L); //client.setTownid(101L); //client.setVillageid(6L); client.setCountyid(2024090516595200202L); client.setTownid(2024090517240900002L); client.setVillageid(2024090517284400002L); client.setBlockid(2024090517155600002L); client.setDivideid(2024090517323800007L); client.setName(name); client.setClientnum("28101006" + String.format("%04d", i+1)); client.setDistrictnum(532328101006L); client.setDistricttitle("元谋县元马镇清和社区居民委员会"); client.setPhone(phone); client.setIdcard(idCard); client.setTypeid(2024090516595201402L); client.setAddress(address); client.setOperator (2024090516595200302L); client.setOperatedt(new Date()); client.setDisabled((byte)0); client.setDeleted((byte)0); Integer rec = clientSv.addClient(client); } else if(town.trim().equals("老城乡2号")) { SeClient client = new SeClient(); //client.setCountyid(28L); //client.setTownid(202L); //client.setVillageid(204L); client.setCountyid(2024090516595200202L); client.setTownid(2024090517252600002L); client.setVillageid(2024090517294000002L); client.setBlockid(2024090517155600002L); client.setDivideid(2024090517355700007L); client.setName(name); client.setClientnum("28202204" + String.format("%04d", i)); client.setDistrictnum(532328202204L); client.setDistricttitle("元谋县老城乡挨小村民委员会"); client.setPhone(phone); client.setIdcard(idCard); client.setTypeid(2024090516595201402L); client.setAddress(address); client.setOperator (2024090516595200302L); client.setOperatedt(new Date()); client.setDisabled((byte)0); client.setDeleted((byte)0); Integer rec = clientSv.addClient(client); } System.out.println("-----------------------------: " + i); } } return BaseResponseUtils.buildSuccess(); } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/clientTemp/ClientTempSv.java
New file @@ -0,0 +1,31 @@ package com.dy.pipIrrSell.clientTemp; import com.dy.pipIrrGlobal.daoSe.SeClientMapper; import com.dy.pipIrrGlobal.daoSe.SeClientTempMapper; import com.dy.pipIrrGlobal.pojoSe.SeClientTemp; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * @author ZhuBaoMin * @date 2024-09-26 15:03 * @LastEditTime 2024-09-26 15:03 * @Description */ @Slf4j @Service public class ClientTempSv { @Autowired private SeClientTempMapper seClientTempMapper; @Autowired private SeClientMapper seClientMapper; public List<SeClientTemp> getClientsByTownName(String townName ) { return seClientTempMapper.getClientsByTownName(townName); } }