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 importClient(String townName){ List 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(); } }