|
@@ -16,7 +16,10 @@ import com.tofly.fees.common.dbhelper.DbHelper;
|
|
|
import com.tofly.fees.common.dbhelper.LogHelper;
|
|
|
import com.tofly.fees.common.dbhelper.PageSortHelper;
|
|
|
import com.tofly.fees.common.dbhelper.ProduceSql;
|
|
|
+import com.tofly.fees.common.model.ProcParamModel;
|
|
|
+import com.tofly.fees.common.util.DateUtils;
|
|
|
import com.tofly.fees.common.util.NumberUtils;
|
|
|
+import com.tofly.fees.common.util.SysConfigUtils;
|
|
|
import com.tofly.fees.meterprofilemgt.entity.DaMeter;
|
|
|
import com.tofly.fees.meterprofilemgt.service.DaMeterService;
|
|
|
import com.tofly.fees.meterreadingmgt.entity.BwMeterReadPlan;
|
|
@@ -28,14 +31,20 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.ibatis.mapping.ParameterMode;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.sql.JDBCType;
|
|
|
+import java.text.MessageFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
|
|
|
|
|
* 抄表计划_抄表录入
|
|
@@ -269,4 +278,124 @@ public class BwMeterReadPlanController extends BaseController {
|
|
|
IPage<Map<String, Object>> pageList = bwMeterReadPlanMapper.getUserList(page, companyBranch, mrBooks, searchText);
|
|
|
return ResultRespone.success(pageList);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 抄表算费-按选中用户算费
|
|
|
+ *
|
|
|
+ * @param meterCardIds 抄表卡ID集(多个英文逗号隔开)
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/doCalcFeeForUser")
|
|
|
+ @ApiOperation(value = "抄表算费-按选中用户算费")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "meterCardIds", value = "抄表卡ID集(多个英文逗号隔开)", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone doCalcFeeForUser(String meterCardIds) throws Exception {
|
|
|
+ if (StringUtils.isBlank(meterCardIds)) {
|
|
|
+ return ResultRespone.failed("算费失败:请选择需要算费的用户!");
|
|
|
+ }
|
|
|
+ String[] arrCardIds = meterCardIds.split(",");
|
|
|
+ return getResultResponse(arrCardIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 抄表算费-按选中抄表册
|
|
|
+ *
|
|
|
+ * @param mrBooks 抄表册编码集(多个英文逗号隔开)
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/doCalcFeeForMrBook")
|
|
|
+ @ApiOperation(value = "抄表算费-按选中抄表册")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "mrBooks", value = "抄表册编码集(多个英文逗号隔开)", dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone doCalcFeeForMrBook(String mrBooks) throws Exception {
|
|
|
+ if (StringUtils.isBlank(mrBooks)) {
|
|
|
+ return ResultRespone.failed("算费失败:抄表册参数为空!");
|
|
|
+ }
|
|
|
+ ArrayList arrayList = bwMeterReadPlanMapper.getMeterCardIds(mrBooks);
|
|
|
+ if (arrayList.size() == 0) {
|
|
|
+ return ResultRespone.failed("算费失败:当前所选的抄表册不存在需算费的用户!");
|
|
|
+ }
|
|
|
+ String[] arrList = (String[]) arrayList.toArray();
|
|
|
+ return getResultResponse(arrList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 算费相关处理
|
|
|
+ *
|
|
|
+ * @param arrCardIds 抄表卡ID集数组
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private ResultRespone<Object> getResultResponse(String[] arrCardIds) throws Exception {
|
|
|
+ int maxCalcNum = Integer.parseInt(SysConfigUtils.getConfigValue("CBJSMaxCount"));
|
|
|
+ if (arrCardIds.length > maxCalcNum) {
|
|
|
+ return ResultRespone.failed(MessageFormat.format("算费失败:选择的【{0}】条抄表记录过多,每次算费最多不超过【{1}】条记录,请分批计算费用!", arrCardIds.length, maxCalcNum));
|
|
|
+ }
|
|
|
+ DbHelper db = DbHelper.getDbHelper();
|
|
|
+
|
|
|
+ List<ProcParamModel> listZB = new ArrayList<>();
|
|
|
+ listZB.add(new ProcParamModel("P_CBKID", ParameterMode.IN, JDBCType.INTEGER, null));
|
|
|
+ listZB.add(new ProcParamModel("P_SFCG", ParameterMode.OUT, JDBCType.INTEGER, 0));
|
|
|
+ listZB.add(new ProcParamModel("P_MSG", ParameterMode.OUT, JDBCType.VARCHAR, ""));
|
|
|
+ Map mapZB = db.excuteProcedure("PROC_SLJS_ZB", listZB);
|
|
|
+
|
|
|
+
|
|
|
+ if (!(mapZB != null && mapZB.get("P_SFCG").equals(1))) {
|
|
|
+ return ResultRespone.failed(MessageFormat.format("算费失败:总表水量计算异常【异常消息:{0}】,已终止!", mapZB.get("P_MSG")));
|
|
|
+ }
|
|
|
+
|
|
|
+ ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
|
|
|
+ for (String meterCardId : arrCardIds) {
|
|
|
+ queue.add(meterCardId);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date dtBegin = new Date();
|
|
|
+
|
|
|
+ int intSuccessNum = doRunDataQueue(db, queue);
|
|
|
+
|
|
|
+ Date dtEnd = new Date();
|
|
|
+
|
|
|
+ long secNum = DateUtils.getSecond(dtBegin, dtEnd);
|
|
|
+
|
|
|
+ String strMsg = "";
|
|
|
+ if (intSuccessNum == 0) {
|
|
|
+ strMsg = MessageFormat.format("算费失败:已算费0条抄表记录!共耗时{0}秒!", secNum);
|
|
|
+ } else {
|
|
|
+ strMsg = MessageFormat.format("算费成功:成功算费{0}个用户,共耗时{1}秒!", intSuccessNum, secNum);
|
|
|
+ }
|
|
|
+ LogHelper.excuteCustom(BwMeterReadPlan.class, "抄表算费:按选中抄表册", strMsg);
|
|
|
+ return (intSuccessNum == 0) ? ResultRespone.failed(strMsg) : ResultRespone.success(strMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 运行数据队列
|
|
|
+ *
|
|
|
+ * @param db 数据处理对象
|
|
|
+ * @param queue 队列对象
|
|
|
+ * @return 运行的成功数
|
|
|
+ */
|
|
|
+ private int doRunDataQueue(DbHelper db, ConcurrentLinkedQueue<String> queue) {
|
|
|
+
|
|
|
+ int intReturnNum = 0;
|
|
|
+ while (!queue.isEmpty()) {
|
|
|
+ String meterCId = queue.poll();
|
|
|
+
|
|
|
+ List<ProcParamModel> listSLSF = new ArrayList<>();
|
|
|
+ listSLSF.add(new ProcParamModel("P_CBKID", ParameterMode.IN, JDBCType.INTEGER, meterCId));
|
|
|
+ listSLSF.add(new ProcParamModel("P_SFCG", ParameterMode.OUT, JDBCType.INTEGER, 0));
|
|
|
+ listSLSF.add(new ProcParamModel("P_MSG", ParameterMode.OUT, JDBCType.VARCHAR, ""));
|
|
|
+ Map mapSLSF = db.excuteProcedure("PROC_SLSFJS", listSLSF);
|
|
|
+
|
|
|
+ if (mapSLSF != null && mapSLSF.get("P_SFCG").equals(1)) {
|
|
|
+ intReturnNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ queue.remove(meterCId);
|
|
|
+ }
|
|
|
+ return intReturnNum;
|
|
|
+ }
|
|
|
}
|