From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能
---
service-report/src/main/java/com/java110/report/bmo/reportInfoAnswerValue/impl/SaveReportInfoAnswerValueBMOImpl.java | 196 ++++++++++++++++++++++++++++++------------------
1 files changed, 121 insertions(+), 75 deletions(-)
diff --git a/service-report/src/main/java/com/java110/report/bmo/reportInfoAnswerValue/impl/SaveReportInfoAnswerValueBMOImpl.java b/service-report/src/main/java/com/java110/report/bmo/reportInfoAnswerValue/impl/SaveReportInfoAnswerValueBMOImpl.java
index f4b8fea..e98db3a 100644
--- a/service-report/src/main/java/com/java110/report/bmo/reportInfoAnswerValue/impl/SaveReportInfoAnswerValueBMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/bmo/reportInfoAnswerValue/impl/SaveReportInfoAnswerValueBMOImpl.java
@@ -4,9 +4,15 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.reportInfoAnswerValue.ReportInfoAnswerValueDto;
import com.java110.dto.reportInfoSetting.ReportInfoSettingDto;
+import com.java110.dto.reportInfoSettingTitleValue.ReportInfoSettingTitleValueDto;
+import com.java110.dto.user.UserDto;
+import com.java110.intf.report.IReportInfoAnswerInnerServiceSMO;
import com.java110.intf.report.IReportInfoAnswerValueInnerServiceSMO;
import com.java110.intf.report.IReportInfoSettingInnerServiceSMO;
+import com.java110.intf.report.IReportInfoSettingTitleValueInnerServiceSMO;
+import com.java110.intf.user.IUserInnerServiceSMO;
import com.java110.po.reportInfoAnswer.ReportInfoAnswerPo;
import com.java110.po.reportInfoAnswerValue.ReportInfoAnswerValuePo;
import com.java110.po.userQuestionAnswer.UserQuestionAnswerPo;
@@ -31,96 +37,136 @@
@Autowired
private IReportInfoSettingInnerServiceSMO reportInfoSettingInnerServiceSMOImpl;
+ @Autowired
+ private IReportInfoAnswerInnerServiceSMO reportInfoAnswerInnerServiceSMOImpl;
+
+ @Autowired
+ private IUserInnerServiceSMO userInnerServiceSMOImpl;
+ @Autowired
+ private IReportInfoSettingTitleValueInnerServiceSMO reportInfoSettingTitleValueInnerServiceSMOImpl;
+
/**
* 娣诲姞灏忓尯淇℃伅
*
- * @param reportInfoAnswerValuePo
+ * @param
* @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
*/
@Java110Transactional
- public ResponseEntity<String> save(ReportInfoAnswerValuePo reportInfoAnswerValuePo, JSONArray questionAnswerTitles) {
- ReportInfoSettingDto reportInfoSettingDto = new ReportInfoSettingDto();
- reportInfoSettingDto.setCommunityId(reportInfoAnswerValuePo.getCommunityId());
- reportInfoSettingDto.setSettingId(reportInfoAnswerValuePo.getSettingId());
- List<ReportInfoSettingDto> reportInfoSettingDtos = reportInfoSettingInnerServiceSMOImpl.queryReportInfoSettings(reportInfoSettingDto);
- Assert.listOnlyOne(reportInfoSettingDtos, "鐤儏闂嵎涓嶅瓨鍦�");
+ public ResponseEntity<String> save(JSONObject reqJson,String userId) {
-
-
- /* JSONObject titleObj = null;
- ReportInfoAnswerValuePo tmpUserUserQuestionAnswerValue = null;
- List<ReportInfoAnswerValuePo> tmpUserUserQuestionAnswerValues = new ArrayList<>();
- ReportInfoAnswerPo userQuestionAnswerPo = new ReportInfoAnswerPo();
- if(StringUtil.isEmpty(userQuestionAnswerValuePo.getUserQaId()) || userQuestionAnswerValuePo.getUserQaId().startsWith("-")){
- userQuestionAnswerPo.setUserQaId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_userQaId));
- }else{
- userQuestionAnswerPo.setUserQaId(userQuestionAnswerValuePo.getUserQaId());
+ /* UserDto userDto = new UserDto();
+ userDto.setUserId(userId);
+ List<UserDto> userDtoList = userInnerServiceSMOImpl.getUsers(userDto);
+ if (userDtoList == null || userDtoList.size() < 1) {
+ throw new IllegalArgumentException("鏌ヨ鐢ㄦ埛淇℃伅澶辫触锛�");
+ }*/
+ ReportInfoAnswerPo reportInfoAnswerPo = new ReportInfoAnswerPo();
+ reportInfoAnswerPo.setUserAnId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_userAnId));
+ reportInfoAnswerPo.setSettingId(reqJson.getString("settingId"));
+ reportInfoAnswerPo.setPersonId(StringUtil.isNullOrNone(reqJson.getString("personId")) == true?"-1":reqJson.getString("personId"));
+ reportInfoAnswerPo.setPersonName(StringUtil.isNullOrNone(reqJson.getString("personName")) == true?"鏈煡":reqJson.getString("personName"));
+ reportInfoAnswerPo.setCommunityId(reqJson.getString("communityId"));
+ reportInfoAnswerPo.setOpenId(reqJson.getString("openId"));
+ reportInfoAnswerPo.setIdCard(reqJson.getString("idCard"));
+ reportInfoAnswerPo.setTel(reqJson.getString("tel"));
+ int flag = reportInfoAnswerInnerServiceSMOImpl.saveReportInfoAnswer(reportInfoAnswerPo);
+ if (flag < 1) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨澶辫触");
}
+ JSONArray questionAnswerTitles = reqJson.getJSONArray("questionAnswerTitles");
+
+ if (questionAnswerTitles == null || questionAnswerTitles.size() < 1) {
+ throw new IllegalArgumentException("鏈寘鍚鐩強绛旀");
+ }
+ JSONObject titleObj = null;
for (int questionAnswerTitleIndex = 0; questionAnswerTitleIndex < questionAnswerTitles.size(); questionAnswerTitleIndex++) {
titleObj = questionAnswerTitles.getJSONObject(questionAnswerTitleIndex);
- tmpUserUserQuestionAnswerValue = new ReportInfoAnswerValuePo();
- tmpUserUserQuestionAnswerValue.setAnswerType(userQuestionAnswerValuePo.getAnswerType());
- tmpUserUserQuestionAnswerValue.setObjId(userQuestionAnswerValuePo.getObjId());
- tmpUserUserQuestionAnswerValue.setObjType(userQuestionAnswerValuePo.getObjType());
- tmpUserUserQuestionAnswerValue.setPersonId(userQuestionAnswerValuePo.getPersonId());
- tmpUserUserQuestionAnswerValue.setQaId(userQuestionAnswerValuePo.getQaId());
- tmpUserUserQuestionAnswerValue.setScore("0");
- tmpUserUserQuestionAnswerValue.setTitleId(titleObj.getString("titleId"));
- tmpUserUserQuestionAnswerValue.setUserQaId(userQuestionAnswerPo.getUserQaId());
- tmpUserUserQuestionAnswerValue.setUserTitleId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_userTitleId));
- if ("3003".equals(titleObj.getString("titleType"))) {
- tmpUserUserQuestionAnswerValue.setValueId("999");
- tmpUserUserQuestionAnswerValue.setValueContent(titleObj.getString("valueContent"));
- } else {
- tmpUserUserQuestionAnswerValue.setValueId(titleObj.getString("valueContent"));
- tmpUserUserQuestionAnswerValue.setValueContent(titleObj.getString("valueContent"));
+ String titleType = titleObj.getString("titleType");
+ if(ReportInfoAnswerValueDto.TITLETYPE_CHECKBOX.equals(titleType)){
+ JSONArray valueContent = titleObj.getJSONArray("valueContent");
+ if(valueContent == null || valueContent.size() < 1){
+ throw new IllegalArgumentException("澶氶�夐鐩湭鍖呭惈绛旀");
+ }
+ for(int checkBoxIndex = 0;checkBoxIndex<valueContent.size();checkBoxIndex++){
+ ReportInfoAnswerValuePo reportInfoAnswerValuePo = new ReportInfoAnswerValuePo();
+ reportInfoAnswerValuePo.setAnValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_anValueId));
+ reportInfoAnswerValuePo.setUserAnId(reportInfoAnswerPo.getUserAnId());
+ reportInfoAnswerValuePo.setValueId(valueContent.getString(checkBoxIndex));
+ reportInfoAnswerValuePo.setSettingId(reqJson.getString("settingId"));
+ reportInfoAnswerValuePo.setTitleId(titleObj.getString("titleId"));
+ reportInfoAnswerValuePo.setCommunityId(titleObj.getString("communityId"));
+ ReportInfoSettingTitleValueDto reportInfoSettingTitleValueDto = new ReportInfoSettingTitleValueDto();
+
+
+ reportInfoSettingTitleValueDto.setCommunityId(titleObj.getString("communityId"));
+ reportInfoSettingTitleValueDto.setTitleId(titleObj.getString("titleId"));
+ reportInfoSettingTitleValueDto.setValueId(valueContent.getString(checkBoxIndex));
+ List<ReportInfoSettingTitleValueDto> reportInfoSettingTitleValueDtos = reportInfoSettingTitleValueInnerServiceSMOImpl.queryReportInfoSettingTitleValues(reportInfoSettingTitleValueDto);
+ if(reportInfoSettingTitleValueDtos == null || reportInfoSettingTitleValueDtos.size() < 1){
+ throw new IllegalArgumentException("澶氶�夐鐩湭鏌ヨ鍒扮瓟妗堜俊鎭�");
+ }
+ if (valueContent.getString(checkBoxIndex).equals(reportInfoSettingTitleValueDtos.get(0).getValueId())) {
+ reportInfoAnswerValuePo.setValueContent(reportInfoSettingTitleValueDtos.get(0).getQaValue());
+ }
+ flag = reportInfoAnswerValueInnerServiceSMOImpl.saveReportInfoAnswerValue(reportInfoAnswerValuePo);
+ if (flag < 1) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨澶辫触");
+ }
+ }
}
- tmpUserUserQuestionAnswerValues.add(tmpUserUserQuestionAnswerValue);
+ if(ReportInfoAnswerValueDto.TITLETYPE_RADIO.equals(titleType)){
+ String valueContent = titleObj.getString("valueContent");
+ if(valueContent == null || "".equals(valueContent)){
+ throw new IllegalArgumentException("鍗曢�夐鐩湭鍖呭惈绛旀");
+ }
+ ReportInfoAnswerValuePo reportInfoAnswerValuePo = new ReportInfoAnswerValuePo();
+ reportInfoAnswerValuePo.setAnValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_anValueId));
+ reportInfoAnswerValuePo.setUserAnId(reportInfoAnswerPo.getUserAnId());
+ reportInfoAnswerValuePo.setValueId(valueContent);
+ reportInfoAnswerValuePo.setTitleId(titleObj.getString("titleId"));
+ reportInfoAnswerValuePo.setCommunityId(titleObj.getString("communityId"));
+ reportInfoAnswerValuePo.setSettingId(reqJson.getString("settingId"));
+ ReportInfoSettingTitleValueDto reportInfoSettingTitleValueDto = new ReportInfoSettingTitleValueDto();
+
+
+ reportInfoSettingTitleValueDto.setCommunityId(titleObj.getString("communityId"));
+ reportInfoSettingTitleValueDto.setTitleId(titleObj.getString("titleId"));
+ reportInfoSettingTitleValueDto.setValueId(valueContent);
+ List<ReportInfoSettingTitleValueDto> reportInfoSettingTitleValueDtos = reportInfoSettingTitleValueInnerServiceSMOImpl.queryReportInfoSettingTitleValues(reportInfoSettingTitleValueDto);
+ if(reportInfoSettingTitleValueDtos == null || reportInfoSettingTitleValueDtos.size() < 1){
+ throw new IllegalArgumentException("澶氶�夐鐩湭鏌ヨ鍒扮瓟妗堜俊鎭�");
+ }
+ if (valueContent.equals(reportInfoSettingTitleValueDtos.get(0).getValueId())) {
+ reportInfoAnswerValuePo.setValueContent(reportInfoSettingTitleValueDtos.get(0).getQaValue());
+ }
+ flag = reportInfoAnswerValueInnerServiceSMOImpl.saveReportInfoAnswerValue(reportInfoAnswerValuePo);
+ if (flag < 1) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨澶辫触");
+ }
+ }
+ if(ReportInfoAnswerValueDto.ITLETYPE_TEXTAREA.equals(titleType)){
+ String valueContent = titleObj.getString("valueContent");
+ if(valueContent == null || "".equals(valueContent)){
+ throw new IllegalArgumentException("鍗曢�夐鐩湭鍖呭惈绛旀");
+ }
+ ReportInfoAnswerValuePo reportInfoAnswerValuePo = new ReportInfoAnswerValuePo();
+ reportInfoAnswerValuePo.setAnValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_anValueId));
+ reportInfoAnswerValuePo.setUserAnId(reportInfoAnswerPo.getUserAnId());
+ reportInfoAnswerValuePo.setValueId("-1");
+ reportInfoAnswerValuePo.setSettingId(reqJson.getString("settingId"));
+ reportInfoAnswerValuePo.setTitleId(titleObj.getString("titleId"));
+ reportInfoAnswerValuePo.setCommunityId(titleObj.getString("communityId"));
+ reportInfoAnswerValuePo.setValueContent(valueContent);
+
+ flag = reportInfoAnswerValueInnerServiceSMOImpl.saveReportInfoAnswerValue(reportInfoAnswerValuePo);
+ if (flag < 1) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨澶辫触");
+ }
+ }
}
- int flag = userQuestionAnswerValueInnerServiceSMOImpl.saveUserQuestionAnswerValue(tmpUserUserQuestionAnswerValues);
- if (flag < 0) {
- return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "淇濆瓨澶辫触");
- }
- //濡傛灉鏄瀵� 璇勪环 鐩存帴杩斿洖
- String answerType = userQuestionAnswerValuePo.getAnswerType();
-
- if("2003".equals(answerType)){
- userQuestionAnswerPo.setState("1202");
- userQuestionAnswerInnerServiceSMOImpl.updateUserQuestionAnswer(userQuestionAnswerPo);
- return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨鎴愬姛");
- }
-
- userQuestionAnswerPo.setEvaluationScore("0");
- userQuestionAnswerPo.setObjId(userQuestionAnswerValuePo.getObjId());
- userQuestionAnswerPo.setObjType(userQuestionAnswerValuePo.getObjType());
- userQuestionAnswerPo.setPersonId(userQuestionAnswerValuePo.getPersonId());
- userQuestionAnswerPo.setQaId(userQuestionAnswerValuePo.getQaId());
- userQuestionAnswerPo.setScore("0");
-
- if ("2002".equals(questionAnswerDtos.get(0).getQaType())) {
- userQuestionAnswerPo.setState("1201");
- } else {
- userQuestionAnswerPo.setState("1202");
- }
- flag = userQuestionAnswerInnerServiceSMOImpl.saveUserQuestionAnswer(userQuestionAnswerPo);
- if (flag < 0) {
- return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "淇濆瓨澶辫触");
-
- }
-
-*/
-
-
- reportInfoAnswerValuePo.setAnValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_anValueId));
- int flag = reportInfoAnswerValueInnerServiceSMOImpl.saveReportInfoAnswerValue(reportInfoAnswerValuePo);
-
- if (flag > 0) {
return ResultVo.createResponseEntity(ResultVo.CODE_OK, "淇濆瓨鎴愬姛");
- }
-
- return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "淇濆瓨澶辫触");
}
}
--
Gitblit v1.8.0